// 主题混合宏
@mixin themify($themes: $themes) {
  @each $theme, $map in $themes {
    .theme-#{$theme} & {
      $theme-map: () !global;
      
      @each $key, $value in $map {
        $theme-map: map-merge($theme-map, ($key: $value)) !global;
      }
      
      @content;
      
      $theme-map: null !global;
    }
  }
}

// 获取主题值的函数
@function themed($key) {
  @return map-get($theme-map, $key);
}

// 文字样式混合宏
@mixin title-text {
  @include themify {
    font-size: themed('title-size');
    font-weight: themed('title-weight');
    color: themed('primary-color');
  }
}

@mixin subtitle-text {
  @include themify {
    font-size: themed('subtitle-size');
    font-weight: themed('subtitle-weight');
    color: themed('secondary-color');
  }
}

@mixin body-text {
  @include themify {
    font-size: themed('body-size');
    font-weight: themed('body-weight');
    color: themed('text-color');
  }
}

@mixin caption-text {
  @include themify {
    font-size: themed('caption-size');
    font-weight: themed('caption-weight');
    color: themed('caption-color');
  }
}

@mixin button-text {
  @include themify {
    font-size: themed('btn-text-size');
    font-weight: themed('btn-text-weight');
    color: themed('inverse-color');
  }
}

// 背景混合宏
@mixin background {
  @include themify {
    background-color: themed('bg-color');
  }
}

@mixin secondary-background {
  @include themify {
    background-color: themed('bg-secondary-color');
  }
}

@mixin theme-background {
  @include themify {
    background-color: themed('theme-color');
  }
}